<?php

/**
 * User class
 * Static wrapper for user information
 * 
 * @author Wouter Toering
 */
class User
{
	/**
	 * $type
	 * Type gebruiker (-1 = gast/uitgelogd, 1 = leerling, 2 = docent, 3 = klasseTV)
	 */
	private static $type = -1;

	private static $id;
	private static $username;
	private static $classID;
	private static $firstName;
	private static $lastName;

	/**
	 * User - Saves the given data into variables
	 * 
	 * @param int $type
	 * @param int $id
	 * @param string $username
	 * @param string $classID
	 * @param string $firstName
	 * @param string $lastName 
	 */
	function User($type, $id, $username, $classID, $firstName, $lastName)
	{
		self::$type = $type;
		self::$id = $id;
		self::$username = $username;
		self::$classID = $classID;
		self::$firstName = $firstName;
		self::$lastName = $lastName;
	}

	/**
	 * getID()
	 * returns the users ID
	 * 
	 * @return int value of the user's ID (null if not set) 
	 */
	static function getID()
	{
		return self::$id;
	}

	/**
	 * getType()
	 * returns the type of the user, either a number or text representation of the type
	 * 
	 * @param boolean $digit When true, the function will return the digital representation of the type, when false, a text representation will be returned
	 * @return string/int The type of the user
	 */
	static function getType($digit = false)
	{
		if($digit)
			return self::$type;
		
		switch(self::$type)
		{
			case 3:
				$type = 'klassetv';
				break;
			case 2:
				$type = 'docent';
				break;
			case 1:
				$type = 'leerling';
				break;
			default:
				$type = 'gast';
		}

		return $type;
	}

	/**
	 * getUsername()
	 * Returns the user's username
	 * 
	 * @return string The user's username (null if not set)
	 */
	static function getUsername()
	{
		return self::$username;
	}

	/**
	 * getClassID()
	 * Returns the ID of which the user belongs
	 * 
	 * @return int class ID of user (null if not set)
	 */
	static function getClassID()
	{
		return self::$classID;
	}

	/**
	 * getFirstName()
	 * Returns the user's first name
	 * 
	 * @return string users's firstname
	 */
	static function getFirstName()
	{
		return self::$firstName;
	}

	/**
	 * getLastName()
	 * 
	 * Returns the user's last name
	 * 
	 * @return string users's last name
	 */
	static function getLastName()
	{
		return self::$lastName;
	}
}